package com.nhjf.common.util.tools;

import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

/**
 * 配置文件解密类
 * @author huangjingying
 * @company 浙江汇购科技有限公司
 * 2012-4-12
 * sql-webServer
 * com.nhjf.common.util.tools
 * @version 1.0
 *
 */
public class MyConfigurer extends PropertyPlaceholderConfigurer  

{  
  
    @Override  
    protected void processProperties(  
            ConfigurableListableBeanFactory beanFactory, Properties props)  
            throws BeansException {  
  
       
        
        String url = props.getProperty("jdbc.connection.jdbcUrl");
        if(url != null ) {
        	props.setProperty("jdbc.connection.jdbcUrl", DESUtil.getFromBASE64(url));
        }
        String userName = props.getProperty("jdbc.connection.user");
        if (userName != null ) {  
            props.setProperty("jdbc.connection.user", DESUtil.getDesString(userName));  
        }  
        String password = props.getProperty("jdbc.connection.password");  
        if (password != null ) {  
            props.setProperty("jdbc.connection.password", DESUtil.getDesString(password));  
        }
      
        String url2 = props.getProperty("jdbc.connection.jdbcUrl2");
        if(url2 != null ) {
        	props.setProperty("jdbc.connection.jdbcUrl2", DESUtil.getFromBASE64(url2));
        }
        String userName2 = props.getProperty("jdbc.connection.user2");
        if(userName2 != null ) {
        	props.setProperty("jdbc.connection.user2", DESUtil.getDesString(userName2));
        }
        String password2 = props.getProperty("jdbc.connection.password2");
        if(password2 != null){
        	props.setProperty("jdbc.connection.password2", DESUtil.getDesString(password2));
        }
        super.processProperties(beanFactory, props);
  
    }  
}  
